﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Text;
using DotNet.Business;
using DotNet.Model;
using DotNet.Common;
using System.Threading;
using System.Collections.Generic;
public partial class Admin_adminUser : basePage
{
    adminBll aBll = new adminBll();
    roleBll rBll = new roleBll();
    userRoleBll urBll = new userRoleBll();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["action"]!=null)
            {
                string action = Request.QueryString["action"].ToString();
                string uid = Request.QueryString["uid"].ToString();
                switch (action.Trim())
                {
                    case "delAll": 
                        delll(Convert.ToInt32(uid));
                        break;
                    case "delTb":
                        delTb(Convert.ToInt32(uid));
                        break;
                    default:
                        break;
                }
            }
            bindAdmin();
        }
    }

    private void delTb(int p)
    {
        if (p != 0)
        {
           if(urBll.Delete(p,1))
           {
              
           }
        }
    }

    private void bindAdmin()
    {
        this.Repeater1.DataSource = aBll.GetModel();
        this.Repeater1.DataBind();
    }
    public role getRoleById(int adminId)
    {
        role roleModel=null;
        int roleId = urBll.GetModelByAdminId(adminId).Roleid;
        if (roleId != 0)
        {
             roleModel = rBll.GetModel(roleId);
        }
        return roleModel;
    }
    #region 删除用户---郑同飞
    public void delll(int id)
    {
        if (urBll.checkUserByAdminId(id))
        {
            Response.Write("<font color='red'>请先解除关联性</font>");
        }
        else
        aBll.Delete(id);
    }
    #endregion

    

}
